package meterMonitor.biz;

import meterMonitor.mapper.MonitorWeekMapper;
import meterMonitor.model.MonitorWeek;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MonitorWeekBiz {
    public static final Logger logger = LoggerFactory.getLogger(MonitorWeekBiz.class);
    @Autowired
    private MonitorWeekMapper monitorWeekMapper;


    public List<MonitorWeek> query(MonitorWeek monitorWeek) {
        return monitorWeekMapper.query(monitorWeek);
    }

    public List<MonitorWeek> queryData(String fromTime, String toTime, String codes) {
        return monitorWeekMapper.queryData(fromTime, toTime, codes);
    }
    //按周查询
    public List<MonitorWeek> queryDataByWeek(String fromTime,String toTime,String areaId,int deviceTypeCode,String codes){
        return monitorWeekMapper.queryDataByWeek(fromTime, toTime, areaId, deviceTypeCode, codes);
    }

    //这个暂时没用到，用到会标记
    public List<MonitorWeek> queryDataByType(String fromTime,String toTime,String codes,int type){
        return monitorWeekMapper.queryDataByType(fromTime, toTime, codes, type);
    }

    public List<MonitorWeek> queryDetailData(String fromTime, String toTime, String codes) {

        List<MonitorWeek> monitorWeeks = monitorWeekMapper.queryData(fromTime, toTime, codes);
        // for (MonitorWeek m : monitorWeeks) {
        //     if (m.getStandard() < m.getIntervalQuantity()) {
        //         m.setIsOver("是");
        //     } else {
        //         m.setIsOver("否");
        //     }
        //     // 设置当前读数
        //     MonitorWeek monitorDetail = monitorWeekMapper.queryCurrentQuantity(m.getMeterCode(), m.getDay());
        //     if (Objects.nonNull(monitorDetail)) {
        //         m.setCurrentQuantiry(monitorDetail.getCurrentQuantiry());
        //     }
        // }

        return monitorWeeks;
    }

    public MonitorWeek getCurrentByMeterCode(Long meterCode) {
        return monitorWeekMapper.getCurrentByMeterCode(meterCode);
    }
}

